<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body></body>
  <script>
    // 对象解构，只要key存在就有对应的数据，key值不存在就是 undefined
    const obj = { name: 'zs', age: 20 };
    const { name, age, id } = obj;
    console.log('name, age,id -----> ', name, age, id);

    // 数组解构, 按照数组的下标位，逐个解构
    const arr = [1, 2, 3];
    // const a1 = arr[0];
    // const a2 = arr[1];
    // const a3 = arr[2];
    const [a1, , a3] = arr;
    console.log('a1,a3 -----------> ', a1, a3);
  </script>
</html>
